package com.zbkj.crmeb.store.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.store.model.StoreModuleSetUp;
import com.zbkj.crmeb.store.request.StoreModuleSetUpRequest;
import com.zbkj.crmeb.store.response.StoreModuleSetUpResponse;
import com.zbkj.crmeb.store.service.StoreModuleSetUpService;
import com.zbkj.crmeb.store.service.StoreProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 模块设置
 * @Description: 
 * @author duyb
 * @date 2022-10-26
 */
@RestController
@RequestMapping("api/admin/store/module")
@Api(tags = "模块设置")
public class StoreModuleSetUpController {
    @Autowired
    StoreModuleSetUpService storeModuleSetUpService;

    /**
     * 列表
     * @Description:  
     * @author duyb
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "列表")
    @GetMapping("/list")
    public CommonResult<Object> getList() {
        return CommonResult.success(storeModuleSetUpService.getList());
    }
    
    /**
     * 分页查询
     * @Description:  
     * @author duyb
     * @param @param [StoreModuleSetUpRequest PageParamRequest]
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "分页")
    @GetMapping("/page")
    public CommonResult<Object> pageEntity(@ModelAttribute StoreModuleSetUpRequest request, @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<StoreModuleSetUpResponse> setUpResponseCommonPage = CommonPage.restPage(storeModuleSetUpService.pageEntity(request,pageParamRequest));
        return CommonResult.success(setUpResponseCommonPage);
    }
    
    /**
     * 通过id查询
     * @Description:  
     * @author duyb
     * @param @param id
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "通过id获取")
    @GetMapping("/{id}")
    public CommonResult<Object> getEntity(@PathVariable("id") Integer id) {
        return CommonResult.success(storeModuleSetUpService.getEntity(id));
    }


    /**
     * 去除下架商品
     * @Description:
     * @author duyb
     * @param @param id
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "去除下架商品")
    @PostMapping("/screen/{id}")
    public CommonResult<Object> screenProduct(@PathVariable("id") Integer id) {
        return CommonResult.success(storeModuleSetUpService.screenProduct(id));
    }
    
    /**
     * 新增/修改
     * @Description:  
     * @author duyb
     * @param @param storeModuleSetUpRequest
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "新增/修改")
    @PostMapping("/save")
    public CommonResult<Object> save(@RequestBody StoreModuleSetUpRequest storeModuleSetUpRequest) {
        return CommonResult.success(storeModuleSetUpService.saveEntity(storeModuleSetUpRequest));
    }
    
    @PutMapping("/is-enabled/{id}/update/{status}")
    @ApiOperation("禁用或启用")
    public CommonResult<Object> enabled(@ApiParam(value = "主键id", required = true) @PathVariable("id") Integer id, @ApiParam(value = "启用状态 1启用 0 禁用", required = true) @PathVariable("status") Integer status) {
        return CommonResult.success(storeModuleSetUpService.enabled(id,status));
    }
    
    /**
     * 根据id删除
     * @Description:  
     * @author duyb
     * @param @param id
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/{id}")
    public CommonResult<Object> del(@PathVariable("id") Integer id) {
        return CommonResult.success(storeModuleSetUpService.removeById(id));
    }


}
